package fields;

import game.*;

public class Brewery extends Ownable {

	private int baseRent;
	
	public Brewery(int number, String name, int price) {
		
		super(number, name, price);
	}
	
	public void landOnField(Player sp)
	{
		if (!isOwnable() && sp!=owner && !sp.isInJail() && !isPawned())
		{ 
		setRent(sp.getDice());
		sp.transfer(getRent(), owner);
		}
		else if (isOwnable()){
			if (sp.getChoice()) {
				buy(sp);
				sp.setChoice(false);
			}
		}
	}
	
	public String fieldInfo(Player p) {
		if (isPawned()) return "This field is pawned!";
		if (isOwnable()) return this.getName()+" is ownable!";
		else if (owner.isInJail()) return "The owner is in jail. It is free to park.";
		else if (p.isOwner(this)) return "You are the owner of "+this.getName();
		else {
			setRent(p.getDice());
			return this.getName()+" is owned by "+this.getOwnerName()+". Pay "+getRent();
		}
	}
	
	public void setRent(int dice)
	
	{
		baseRent = dice*100*owner.numberOfBreweries();
	}
	
	public int getRent()
	{
		return baseRent;
	}	
	
}